package com.xiaocikuai.smallchunks;

import com.corundumstudio.socketio.SocketIOServer;
import com.xiaocikuai.smallchunks.utils.SessionListener;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@MapperScan("com.xiaocikuai.smallchunks.mapper")
@EnableScheduling
public class SmallchunksApplication {

//    @Autowired
//    private SocketIOServer socketIOServer;
    public static void main(String[] args) {
        SpringApplication.run(SmallchunksApplication.class, args);
    }


//    @Bean
//    public ApplicationRunner runner() {
//        return args -> {
//            socketIOServer.addEventListener("offer", String.class, (client, data, ackRequest) -> {
//                client.getNamespace().getBroadcastOperations().sendEvent("offer", data);
//            });
//
//            socketIOServer.addEventListener("answer", String.class, (client, data, ackRequest) -> {
//                client.getNamespace().getBroadcastOperations().sendEvent("answer", data);
//            });
//
//            socketIOServer.addEventListener("candidate", String.class, (client, data, ackRequest) -> {
//                client.getNamespace().getBroadcastOperations().sendEvent("candidate", data);
//            });
//
//            socketIOServer.start();
//        };
//    }
}
